<?php

	include_once('./mvc/modelo/Accesatabla.php');
	include_once('./mvc/modelo/diseno.php');
	$potreros = new Accesatabla('potreros');
	$ds = new Diseno();
	$n=1;
	$p = $potreros->buscardonde('ID > 0');
	if(!empty($p)){

		$cont ='<center>
					<div class="row">
						<div class="col-sm-12 col-md-12 col-lg-12">	
							<a href="./?url=inicio" title="Regresar" class="btn btn-primary pull-left"><span class="glyphicon glyphicon-arrow-left"></span></a>
							<h3>Potreros</h3><hr>							
						</div>
					</div>
					<div class="overthrow" style="overflow:auto;">
						<table class="table table-bordered">
							<tr class="info">
								<th>#</th>
								<th>C&oacute;digo del Potrero</th>
								<th>Descripci&oacute;n</th>
								<th>Editar Potrero</th>
								<th>Asociar Ganado</th>
								<th>Ver Ganado</th>
							</tr>';
		
		while ($p){
		
			$cont .='<tr>
						<td>'.$n.'</td>
						<td>'.$potreros->obtener('COD_POTRERO').'</td>
						<td>'.$potreros->obtener('DESCRIPCION').'</td>
						<td><a href="./?url=potreros&id='.$potreros->obtener('ID').'" title="Editar" class="btn btn-success"><span class="glyphicon glyphicon-edit"></span></a></td>
						<td><a href="./?url=ganadopotrero&id='.$potreros->obtener('ID').'" title="Asociar" class="btn btn-success"><span class="glyphicon glyphicon-plus"></span></a></td>
						<td><a href="./?url=show_potreros_ganado&id='.$potreros->obtener('ID').'" title="Ver" class="btn btn-success"><span class="glyphicon glyphicon-eye-open"></span></a></td>
					</tr>';
			$p = $potreros->releer();
			$n++;
		}
		$cont.='
						</table>	
					</div>
					<a href="./?url=potreros" class="btn btn-primary">Agregar Potrero Nuevo	</a>					
				</center>';
	}else{
		$cont .= '<center>
					<h4>No hay potreros registrados</h4>
					<a href="./?url=potreros" class="btn btn-primary">Ir a Potreros</a>
				</center>';		
	}	
	
	$ds->contenido($cont); 
	$ds->mostrar();
	
	
?>